package com.hjx.objectassert;

import com.hjx.objectassert.model.BillAllData;
import com.hjx.objectassert.model.CreditCardAllData;
import com.hjx.objectassert.model.CreditCardTimeDeposit;
import org.junit.Assert;
import org.junit.Test;

import java.math.BigDecimal;
import java.util.*;

public class AssertTwoObject {

    @Test
    public void test(){

        //except
        CreditCardAllData except = new CreditCardAllData();
        except.setBalance(new BigDecimal(100));

        CreditCardAllData actual = new CreditCardAllData();
        actual.setBalance(new BigDecimal(1200));

        Assert.assertEquals(actual, except);


    }

    @Test
    public void test1(){

        //except
        CreditCardAllData except = new CreditCardAllData();
        except.setBankName("PSBC");
        ArrayList<CreditCardTimeDeposit> deposits = new ArrayList<CreditCardTimeDeposit>();

        CreditCardTimeDeposit creditCardTimeDeposit1 = new CreditCardTimeDeposit();
        creditCardTimeDeposit1.setBalance(new BigDecimal(100));
        deposits.add(creditCardTimeDeposit1);

        CreditCardTimeDeposit creditCardTimeDeposit2 = new CreditCardTimeDeposit();
        creditCardTimeDeposit2.setBalance(new BigDecimal(200));
        deposits.add(creditCardTimeDeposit2);

        except.setDeposits(deposits);

        List<BillAllData> bills = new ArrayList<BillAllData>();
        BillAllData billAllData = new BillAllData();
        billAllData.setBillId(UUID.randomUUID().toString());
        bills.add(billAllData);
        except.setBills(bills);


        //actual
        CreditCardAllData actual = new CreditCardAllData();
        actual.setBankName("PSBC1");
        ArrayList<CreditCardTimeDeposit> deposits1 = new ArrayList<CreditCardTimeDeposit>();

        CreditCardTimeDeposit creditCardTimeDeposit3 = new CreditCardTimeDeposit();
        creditCardTimeDeposit3.setBalance(new BigDecimal(200));
        deposits1.add(creditCardTimeDeposit3);

        CreditCardTimeDeposit creditCardTimeDeposit4 = new CreditCardTimeDeposit();
        creditCardTimeDeposit4.setBalance(new BigDecimal(100));
        deposits1.add(creditCardTimeDeposit4);

        actual.setDeposits(deposits1);

        List<BillAllData> bills1 = new ArrayList<BillAllData>();
        BillAllData billAllData1 = new BillAllData();
        billAllData1.setBillId(billAllData.getBillId());
        bills1.add(billAllData1);
        actual.setBills(bills1);

        Assert.assertEquals(actual, except);


    }

    @Test
    public void testSort() {
        List<Integer> actual = Arrays.asList(new Integer[]{ 1, 3, 2, 4});
        Collections.sort(actual);
        List<Integer> except = Arrays.asList( new Integer[]{1, 2, 4, 3});
        Assert.assertArrayEquals(actual.toArray(), except.toArray());
    }

    @Test
    public void testHashMap() {
        Map<String, String> actual = new HashMap<String, String>(){{
            put("a", "1");
        }};

        Map<String, String> except = new HashMap<String, String>(){{
            put("a", "2");
        }};

        Assert.assertEquals(actual, except);
    }
}
